package cn.phecda.boot.data.jpa.support;

import cn.phecda.boot.common.lang.model.BaseEntity;
import jakarta.persistence.QueryHint;
import org.hibernate.jpa.AvailableHints;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.lang.NonNull;

import java.io.Serializable;
import java.util.Optional;

/**
 * <p> 基础仓库 </p>
 *
 * @author : wanpinwei
 */
@NoRepositoryBean
public interface CommonJpaRepository<E extends BaseEntity, ID extends Serializable> extends JpaRepository<E, ID>, JpaSpecificationExecutor<E> {


    @Override
    @NonNull
    @QueryHints(@QueryHint(name = AvailableHints.HINT_CACHEABLE, value = "true"))
    Optional<E> findById(@NonNull ID id);
}
